package com.gjy.exception;

import org.junit.jupiter.api.Test;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-02-17 16:34:33
 */
public class ErrorTest {

    @Test
    public void test4() {
        while (true){

        }
    }

    @Test
    public void test1() {
        // java.lang.StackOverflowError
        a();
    }

    @Test
    public void test2() {
        System.out.println("b() = " + b());
    }

    private String b() {
        // Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            s.append("HELLO WORLD");
        }
        return s.toString();
    }

    private void a() {
        a();
    }
}
